package com.haoan.index.service.impl;


import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haoan.index.common.enums.ValiFlag;

import com.haoan.index.mapper.LcTrendsMapper;
import com.haoan.index.domain.LcTrends;
import com.haoan.index.service.LcTrendsService;

/**
 * 存储业内动态信息的Service业务层处理
 * 
 * @author autoGen
 * @date 2025-03-19
 */
@Service
public class LcTrendsServiceImpl extends ServiceImpl<LcTrendsMapper,LcTrends> implements LcTrendsService
{
    @Resource
    private LcTrendsMapper lcTrendsMapper;
    /**
     * 查询存储业内动态信息的
     * 
     * @param id 存储业内动态信息的主键
     * @return 存储业内动态信息的
     */
    @Override
    public LcTrends selectLcTrendsById(Long id)
    {
        return baseMapper.selectById(id);
    }

    /**
     * 查询存储业内动态信息的列表
     * 
     * @param lcTrends 存储业内动态信息的
     * @return 存储业内动态信息的
     */
    @Override
    public List<LcTrends> selectLcTrendsList(LcTrends lcTrends)
    {
        LambdaQueryWrapper<LcTrends> queryWrapper = new LambdaQueryWrapper<>();
        //todo 添加查询条件
        queryWrapper.eq(lcTrends.getId() != null, LcTrends::getId, lcTrends.getId());
        queryWrapper.eq(lcTrends.getTitle() != null, LcTrends::getTitle, lcTrends.getTitle());
        queryWrapper.eq(lcTrends.getPublishDate() != null, LcTrends::getPublishDate, lcTrends.getPublishDate());
        queryWrapper.eq(lcTrends.getContent() != null, LcTrends::getContent, lcTrends.getContent());
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 新增存储业内动态信息的
     * 
     * @param lcTrends 存储业内动态信息的
     * @return 结果
     */
    @Transactional
    @Override
    public int insertLcTrends(LcTrends lcTrends)
    {
        return baseMapper.insert(lcTrends);
    }

    /**
     * 修改存储业内动态信息的
     * 
     * @param lcTrends 存储业内动态信息的
     * @return 结果
     */
    @Transactional
    @Override
    public int updateLcTrends(LcTrends lcTrends)
    {
        return baseMapper.updateById(lcTrends);
    }

    /**
     * 批量删除存储业内动态信息的
     * 
     * @param ids 需要删除的存储业内动态信息的主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteLcTrendsByIds(Long [] ids)
    {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除存储业内动态信息的信息
     * 
     * @param id 存储业内动态信息的主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteById(Long id)
    {
        return baseMapper.deleteById(id);
    }


    /**
     * 根据分页查询相应业内动态信息列表
     * @return
     */
    @Override
    public List<LcTrends> selectLcTrendsListToPage() {
        LambdaQueryWrapper<LcTrends> queryWrapper = new LambdaQueryWrapper<>();
        return baseMapper.selectList(queryWrapper);
    }
}
